<?php get_header(); ?>

	<main id="main" role="main">
		<!-- section -->
		<section id="content">
			<?php /* ?>
			<div id="slide">
				<img src="<?php echo get_template_directory_uri(); ?>/img/img-slide1.jpg" alt="">
			</div>
			<?php */ ?>
			<div id="destaque_home">
				<?php
				$query = new WP_Query(array(
					'post_type'              => 'noticia',
					'posts_per_page'         => '4',
				));
				if ($query->have_posts()):
					$count = 0;
					while ($query->have_posts()) : $query->the_post();
						if($count == 0):
							?>
							<div class="noticias-destaque">
								<h2>Destaques</h2>
								<!-- article -->
								<article id="post-<?php the_ID(); ?>" <?php post_class('destaque'); ?>>
									<?php if (has_post_thumbnail(get_the_ID())) {?>
									<div class="img"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('noticia-home'); ?></a></div>
									<?php } ?>
									<div class="content <?php if(!has_post_thumbnail(get_the_ID())) echo 'noImg'; ?>">
										<strong class="data"><?php the_time('d.m.Y'); ?></strong>
										<h3 class="t1"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
										<div class="txt"><p><a href="<?php the_permalink(); ?>"><?php echo limitar(strip_tags(get_the_content()), has_post_thumbnail(get_the_ID()) ?100:200 ); ?></a></p></div>
										<a href="<?php the_permalink(); ?>" title="Leia mais" class="bt-leiamais fr">Leia mais</a>
									</div>
									<br class="clear">
								</article>
								<!-- /article -->
							</div>
							<?php
						else:
							$listNoticias .= "<li class='".($count == 1 ? "clr" : "")."'><a href='".get_permalink()."'>".limitar(get_the_title(), 90)."</a></li>";
						endif;
						$count++;
					endwhile;
					if($query->post_count > 1):
					?>
						<div class="noticias-home">
							<h2>NOTÍCIAS</h2>
							<ul>
								<?php echo $listNoticias; ?>
							</ul>
							<a href="<?php echo esc_url( home_url( '/noticias' ) ); ?>" title="Leia mais" class="bt-leiamais fr">Leia mais</a>
						</div>
					<?php
					endif;
				endif;
				wp_reset_postdata();
				?>
				<div class="box-instituicao">
					<h2>INSTITUIÇÃO</h2>
					<?php setup_postdata( 27 ); ?>
					<img src="<?php echo get_template_directory_uri(); ?>/img/img-instituicaohome.png" alt="">
					<a href="<?php echo get_permalink(27); ?>"><?php echo get_the_excerpt_by_id(27); ?></a>
					<a href="<?php echo get_permalink(27); ?>" title="Leia mais" class="bt-leiamais fr">Leia mais</a>
				</div>
			</div>

			<?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('miniatura-home')) ?>
		</section>
		<!-- /section -->
		<?php get_sidebar(); ?>
	</main>


<?php get_footer(); ?>
